import time


class Student(object):
    def __init__(self, name, stu_id, age, class_id):
        self.__name = name
        self.__stu_id = stu_id
        self.__age = age
        self.__class_id = class_id

    @property
    def name(self):
        return self.__name

    @name.setter
    def name(self, name):
        self.__name = name

    @property
    def stu_id(self):
        return self.__stu_id

    @stu_id.setter
    def stu_id(self, stu_id):
        self.__stu_id = stu_id

    @property
    def age(self):
        return self.__age

    @age.setter
    def age(self, age):
        self.__age = age

    @property
    def class_id(self):
        return self.__class_id

    @class_id.setter
    def class_id(self, class_id):
        self.__class_id = class_id

    def __str__(self):
        return f"姓名{self.__name},年龄{self.__age},学号{self.__stu_id},班级{self.__class_id}"


class Professor(object):
    def __init__(self, name, stu_info):
        self.name = name
        self.stu_info = stu_info

    def Add_stu(self, stu):
        self.stu_info.append(stu)


stu1 = Student('张三', 1001, 19, 102)
stu2 = Student('小黑', 1002, 22, 101)
stu3 = Student('李四', 1003, 50, 103)
stu_list = [stu1, stu2, stu3]

pro1 = Professor('李教授', stu_list)
stu4 = Student('张杰', 1004, 14, 104)
pro1.Add_stu(stu4)
print(pro1.stu_info)


# 2.实现一个装饰器，该装饰器可以打印出被装饰函数的执行时间
class Homework(object):
    def __init__(self, x):
        self.__x = x



    @property
    def x(self):
        '''
        这里这行函数功能体
        :return:
        '''
        start = time.time()
        for i in range(100):
            print('1', end='')
        print()
        ed = time.time()
        print(ed - start)
        return self.__x

    @x.setter
    def x(self, x):
        self.__x = x


h2 = Homework('测试')
print(h2.x)


# 3.使用两种方法实现字符串"abc123"倒序排列"321cba"
s1 = 'abc123'
print(s1[::-1])

s2 = 'abc123'
l1 = list(s2)
l1.reverse()
print(''.join(l1))
